from shapely.geometry import LineString

length = 1024
pad = 128
stroke = 60

points = [
    (pad, pad),
    (length - pad, pad),
    (length - pad, pad),

]

print(points)

main_points = [
    (length / 2, pad),
    ((length - 2 * pad) / 6 + pad, length - pad),
    (length - pad, (length - 2 * pad) / 3 + pad),
    (pad, (length - 2 * pad) / 3 + pad),
    (pad + (length - 2 * pad) / 6 * 5, length - pad)
]

points = [
    main_points[0],
    LineString([main_points[0], main_points[1]]).intersection(LineString([main_points[2], main_points[3]])).bounds[:2],
    main_points[3],
    LineString([main_points[0], main_points[1]]).intersection(LineString([main_points[3], main_points[4]])).bounds[:2],
    main_points[1],
    LineString([main_points[1], main_points[2]]).intersection(LineString([main_points[3], main_points[4]])).bounds[:2],
    main_points[4],
    LineString([main_points[1], main_points[2]]).intersection(LineString([main_points[4], main_points[0]])).bounds[:2],
    main_points[2],
    LineString([main_points[2], main_points[3]]).intersection(LineString([main_points[4], main_points[0]])).bounds[:2],
]


svg_template = """<svg width="1024" height="1024" xmlns="http://www.w3.org/2000/svg">
    <path d="{path}" fill="none" stroke="black" stroke-width="60" stroke-linecap="round" stroke-linejoin="round"/>
</svg>"""

path = ""
for i in range(len(points)):
    if i == 0:
        path += f"M{points[i][0]},{points[i][1]} "
    else:
        path += f"L{points[i][0]},{points[i][1]} "
path += "Z"
svg = svg_template.format(path=path)
print(svg)
